#! /bin/bash
# a simple script to archive of the munipack

export TMP=/var/tmp/exclude_munipack
export NAME_OLD=munipack-*.*.*/

cd $HOME
echo -n "Last modification: " > $NAME_OLD/archive.log 
date >> $NAME_OLD/archive.log

# increment the version 
if [ ! -e $NAME_OLD/VERSION ] 
then
   echo "Version not found."
   exit 0
fi
export NAME=`cat $NAME_OLD/VERSION | awk -F . '{ print $1 "."  $2 "." $3+1}'`
mv $NAME_OLD $NAME
echo $NAME > $NAME/VERSION

if [ -x $NAME/configure ] 
then
   mv -i $NAME/configure $NAME/configure.sh
fi

rm -rf $NAME/debian/tmp/
make -C $NAME clean
find $NAME/ \( -perm -+x -a ! -type d -a ! -name "*.sh" -a ! -name "*.pl" \) -o \
               -name "*.o" -o -name "*~" -o -name "*.vo"  -o \
               -name "*.a" -o -name "*.fits" -o -name "*.fts" -o \
               -name "V*.inc" -o "*.ps" > $TMP
echo configure >> $TMP
tar cf $NAME.tar $NAME -p -X $TMP --atime-preserve
gzip $NAME.tar
rm $TMP

